// pages/aduting/retreat/retreat_detail.js
var util = require('../../../utils/util.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    room_id: '',
    hiddenmodalput: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getStorage({
      key: 'userInfo',
      success: function (res) {
        that.setData({
          userInfo: res.data,
          id: options.id,
          change_room_id: options.hfid
        })

        util.getReq("/app/my/changeRoomDetail", {
          source: res.data.source,
          uid: res.data.user_id,
          'order.order_id': that.data.id,
          'user.source': that.data.userInfo.source,
          'user.user_id': that.data.userInfo.uid,
          'user.user_name': that.data.userInfo.name,
          'order.change_room_id': that.data.change_room_id
        }, function (datas) {
          console.log(datas);
          if (datas.code == 0) {
           
            that.setData({
              resversionDetail: datas.data,
              begin_lease_time: util.format(datas.data.begin_lease_time, 'yyyy-MM-dd'),
              plan_end_time: util.format(datas.data.plan_end_time, 'yyyy-MM-dd'),
              next_date: util.format(datas.data.next_date, 'yyyy-MM-dd'),
              change_room_time: util.format(datas.data.change_room_time, 'yyyy-MM-dd'),
            })

          } else {
            wx.showToast({
              title: datas.desc,
            })
          }
        })
      }, fail: function () {
        wx.redirectTo({
          url: '/pages/index/index',
        })
      }
    });
  },
  bindAgree: function (e) {

    wx.navigateTo({
      url: '/pages/aduting/hf/hf_option?id='+this.data.id,
    })
  }

})